---
title: "NATS sink"
sidebarTitle: "NATS sink"
description: "Reference for configuring and using the NATS sink with Sequin."
---

The NATS sink publishes messages to NATS subjects.

<Tip>
  This is the reference for the NATS sink. See the [quickstart](/quickstart/nats) for a step-by-step walkthrough or the [how-to guide](/how-to/stream-postgres-to-nats) for an explanation of how to use the NATS sink.
</Tip>

## Configuration

- **Host**

    The hostname of your NATS server (e.g., `localhost`).

- **Port**

    The port number for your NATS server (default: `4222`).

- **Username** (optional)

    Username for authentication with the NATS server.

- **Password** (optional)

    Password for authentication with the NATS server.

- **JWT** (optional)

    JSON Web Token for authentication with the NATS server.

- **NKey Seed** (optional)

    NKey seed for authentication with the NATS server.

- **TLS** (optional)

    Enable TLS/SSL for secure connections to the NATS server (default: `false`).

## Message format

Sequin sends messages to NATS as JSON. You can find the shape of the messages in the [messages reference](/reference/messages).

## Subject naming

By default, messages are published to subjects using the following pattern:

```
sequin.<database_name>.<schema_name>.<table_name>.<action>
```

For example, if you're streaming changes from a table called `products` in the `public` schema of a database called `shop`, you would see subjects like:

- `sequin.shop_prod.public.products.insert`
- `sequin.shop_prod.public.products.update`
- `sequin.shop_prod.public.products.delete`

You can use a [routing function](/reference/routing) to generate your own dynamic subjects.

## Message headers

Each message includes the following NATS headers:

- `Nats-Msg-Id`: A unique Sequin identifier for the message

## Retry behavior

If Sequin is unable to deliver a message to NATS, it will retry the message indefinitely. Sequin will exponentially back off the retry interval, with a maximum backoff of roughly 3 minutes.

## Message ordering

NATS preserves message order within a subject. Messages are published to NATS subjects in the same order that they are received from your source table.

<Note>
  NATS does not support ordering for message consumption. If you consume messages from a NATS subject with multiple, parallel consumers, you may not receive messages in the same order that they were published.
</Note>

## Debugging

You can view the status of your NATS sink in the Sequin web console.

On the "Messages" tab, you can see which messages are in-flight to NATS, which messages Sequin is unable to deliver, and recently delivered messages.

Messages that Sequin is unable to deliver will have a "Deliver count" greater than `1`. You can click on a message to see more details, including the last error response received from NATS.
